﻿using System.Net;
using BusinessFacade;
using Orleans;
using Orleans.Configuration;


namespace Login
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 连接服务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btncon_Click(object sender, EventArgs e)
        {

            var client = new ClientBuilder()
            .UseStaticClustering(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 30000))//192.168.176.127:30000
            .Configure<ClusterOptions>(options =>
            {
                options.ClusterId = "dev";       // 设置 ClusterId
                options.ServiceId = "HelloWorldApp";  // 设置 ServiceId
            })
            .Build();

            await client.Connect();
            Console.WriteLine("Orleans Client Connected.");

            var helloGrain = client.GetGrain<ITestCommon>(0);
            var result = await helloGrain.GetString("<Mei>","Test Orleans's show");
            Console.WriteLine(result); // 输出: Hello, World!
            MessageBox.Show(result);

        }
    }
}
